class Wall {
    constructor(id, x, y, width, height) {
        this.id = id;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.health = 3;  // 初始生命值为3
        this.maxHealth = 3;
        this.isEdgeWall = false;  // 标记是否为边界墙
    }

    // 渲染墙壁
    render(ctx) {
        // 获取渲染系统的偏移量
        const offsetX = ctx.canvas.offsetX || 0;
        const offsetY = ctx.canvas.offsetY || 0;

        // 根据生命值计算透明度
        const alpha = this.isEdgeWall ? 1 : this.health / this.maxHealth;
        
        // 设置填充颜色，使用rgba实现透明度
        ctx.fillStyle = `rgba(128, 128, 128, ${alpha})`;
        ctx.fillRect(this.x + offsetX, this.y + offsetY, this.width, this.height);
    }

    // 受到伤害
    takeDamage(damage) {
        if (this.isEdgeWall) return;  // 边界墙不受伤害
        
        this.health = Math.max(0, this.health - 1);
        return this.health <= 0;  // 返回是否被摧毁
    }
}